local mishu = fk.CreateSkill {
  name = "th_mishu",
}

mishu:addEffect(fk.TargetSpecified, {
  anim_type = "support",
  can_trigger = function(self, event, target, player, data)
    return target ~= player and player:hasSkill(mishu.name) and data.card and data.card:isCommonTrick() and data.firstTarget and
    table.find(data:getAllTargets(), function(p) return player:inMyAttackRange(p) end)
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askToSkillInvoke(player, {
      skill_name = mishu.name,
      prompt = "#th_mishu-invoke:"..target.id.."::"..data.card:toLogString()
    })
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:loseHp(player, 1, mishu.name)
    if player.dead then return false end
    player:drawCards(2, mishu.name)
    local tos = data:getAllTargets()
    data:setNullified(tos)
    local targets = table.filter(tos, function(p) return player:inMyAttackRange(p) and p:isWounded() end)
    if #targets < 1 then return end
    local to = room:askToChoosePlayers(player, {
      targets = targets,
      min_num = 1,
      max_num = 1,
      prompt = "#th_mishu_recover-ask",
      skill_name = mishu.name,
      cancelable = true
    })
    if #to < 1 then return end
    player.room:recover{
      who = to[1],
      num = 1,
      skillName = mishu.name,
      recoverBy = player
    }
  end,
})

Fk:loadTranslationTable{
  ["th_mishu"] = "秘术",
  [":th_mishu"] = "其他角色使用普通锦囊牌指定你攻击范围内角色为目标后，你可以失去1点体力、摸两张牌并令此牌无效，然后你可以令你攻击范围内的其中一名目标回复1点体力。",

  ["#th_mishu-invoke"] = "秘术：你可失去1点体力令 %src 的 %arg 无效",
  ["#th_mishu_recover-ask"] = "秘术：你可令其中一名目标回复1点体力",
}

return mishu